package com.example.spring_boot;

import com.example.spring_boot.bean.Dog;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        ApplicationContext applicationContext = SpringApplication.run(Application.class, args);
        Dog dog=(Dog) applicationContext.getBean(Dog.class);
        dog.setName("小花狗");
        System.out.println(dog);
        System.out.println(dog.getName());
        Dog dog1 = (Dog) applicationContext.getBean("dog");
        System.out.println(dog1);
        System.out.println(dog1.getName());


        BeanLifeComponent bean = applicationContext.getBean(BeanLifeComponent.class);
         bean.use();
    }

}
